<script setup lang="ts">
import { computed } from 'vue'
import useUserStore from '@/stores/user'

const userStore = useUserStore()

const { permission = '', role } = defineProps<{
  permission?: string
  role: string | string[]
}>()

const show = computed(() => {
  if (!role) {
    return false
  }

  if (!permission) {
    return userStore.hasRoleCode(role)
  } else {
    return userStore.hasRoleCodeByPermission(permission, role)
  }
})
</script>
<template>
  <template v-if="show">
    <slot v-if="$slots.default" />
  </template>
</template>

<style scoped lang="scss"></style>
